package sample.plugin.http.entity;

import androidx.annotation.NonNull;

import java.util.Map;

public class RequestEntity {
    public String name;
    public Kind kind = Kind.GET;
    public String url;
    public Map<String, String> headers;
    public String param;

    @NonNull
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("请求名称：").append(name).append("\n");
        builder.append("请求方式：").append(kind.name).append("\n");
        builder.append("请求地址：").append(url).append("\n");
        if (param != null) {
            builder.append("请求参数：").append(param).append("\n");
        }
        if (headers != null) {
            builder.append("请求头：").append("\n");
            for (Map.Entry<String, String> entry : headers.entrySet()) {
                builder.append("\t").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
            }
        }
        return builder.toString();
    }

    public enum Kind {
        GET("GET"),
        POST("POST"),
        PUT("PUT"),
        DELETE("DELETE");

        private final String name;

        Kind(String name) {
            this.name = name;
        }
    }
}
